<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@ include file="../include/head.jsp" %>
<%@ include file="../include/top.jsp" %>
<%@ include file="../include/left.jsp" %>
<div class="main-content">

    <%@ include file="../include/navigate.jsp" %>
    
    <div class="container">
        <div class="row clearfix ">
            <div class="col-md-12 last ">
                <div class="widget-box" style="hieght:80">
                    <c:if test="${error != null }">
                        <div id="loginError" class="alert alert-danger alert-dismissable">
                            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                            <strong>异常:</strong> ${error}
                        </div>
                    </c:if>
                    <c:if test="${msg != null }">
	                    <div class="alert alert-success alert-dismissable">
	                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
	                        <strong>提示:</strong> ${msg}
	                    </div>
	                </c:if>
                       <div class="widget-box" style="width:20%;height:420px;float:left;">
                         <div class="widget-box-header">
	                        <div >
	                            <div class="title">组管理</div>
	                        </div>
	                        <div class="col-sm-3" style="text-align:right;">
			                    <div class="btn-group-sm" style="padding:2px;">
			                        <a type="button" class="btn btn-default btn-sm glyphicon glyphicon-plus" 
			                           href="${pageContext.request.contextPath}/parameter/toAddGroup"> 新建
			                        </a>
			                    </div>
			                </div>
	                     </div>
                         <div class="widget-box-content" style="padding:15px;">
	                        <div class="dataTables_wrapper form-inline" style="height: 300px; overflow:auto">
	                            <div class="table-responsive">
	                                <table id="groupTable" class="tableComponent table table-hover" width="100%">
	                                    <thead>
	                                    </thead>
	                                    <tbody >
	                                    <c:forEach items="${groupList}" var="group" varStatus="idx">
	                                        <c:if test="true">
	                                            <tr onclick="showParameters(${group.id})">
	                                        </c:if>
	                                        <td >${group.name}</td>
	                                        <td >
						                        <div style="float:right;">
							                        <!-- <a type="button" title="插入参数" class="btn btn-default btn-sm glyphicon glyphicon-plus" 
							                           href="">
							                        </a> -->
							                        <a type="button" title="编辑组信息" class="btn btn-default btn-sm glyphicon glyphicon-edit" 
							                           href="${pageContext.request.contextPath }/parameter/toEditGroup?groupId=${group.id }">
							                        </a>
							                        <a type="button" title="删除组" class="btn btn-default btn-sm glyphicon glyphicon-remove" onclick="openModal('${pageContext.request.contextPath}/parameter/delGroup?groupId=${group.id}','删除组别?','删除的组将无法恢复，是否继续?')"
							                           >
							                        </a>
						                        </div>
	                                        </td>
	                                        <td style="display:none">${group.id}</td>
	                                        
	                                    </c:forEach>
	                                    </tbody>
	                                </table>
	                            </div>
	                        </div>
	                        <!-- <div class="row clearfix " align="center">
	                            <div class="col-md-12">
	                                <nav>
	                                    <ul class="groupPagination pagination-sm">
	
	                                    </ul>
	                                </nav>
	                            </div>
	                        </div> -->

                   		</div>
                   	 </div>
	                 <div class="widget-box" style="width:79.97%;height:420px;float:right;"> 
	                     <div class="widget-box-header">
	                        <div class="col-sm-10">
	                            <div class="title">参数列表</div>
	                        </div>
	                        <div class="btn-group-sm" style="padding:2px;">
			                        <a type="button" class="btn btn-default btn-sm glyphicon glyphicon-plus"
			                           href="${pageContext.request.contextPath}/parameter/toAddParam"> 添加参数
			                        </a>
			                    </div>
	                     </div>
                        <div class="widget-box-content" style="padding:15px;">
	                        <div class="dataTables_wrapper form-inline" style="height: 300px; overflow:auto">
	                            <div class="table-responsive">
	                                <table id="parameterTable" class="tableComponent table table-hover" width="100%">
	                                    <thead>
	                                    	<tr>
		                                        <th>组别</th>
		                                        <th>名称</th>
		                                        <th>参数类型</th>
		                                        <th>参数值</th>
		                                        <th>备注</th>
		                                        <th>操作</th>
	                                    	</tr>
	                                    </thead>
	                                    <tbody >
	                                    <c:forEach items="${paramList}" var="para" varStatus="idx">
	                                        <tr>
		                                        <td >${para.group.name}</td>
		                                        <td >${para.gParamName }</td>
		                                        <td >${para.gParamType }</td>
		                                        <td >${para.gParamValue }</td>
		                                        <td ><a>${para.gParamRemark }</a></td>
		                                        <td>
		                                        	<div style="float:center;">
								                        <a type="button" title="编辑参数信息" class="btn btn-default btn-sm glyphicon glyphicon-edit" 
								                           href="${pageContext.request.contextPath }/parameter/toEditParam?paramId=${para.id }">
								                        </a>
		                                        		<a type="button" title="删除参数信息" class="btn btn-default btn-sm glyphicon glyphicon-remove" 
								                           onclick="openModal('${pageContext.request.contextPath }/parameter/delParam?paramId=${para.id}','确定删除该参数?','删除的参数将无法恢复，是否继续?')">
								                        </a>
								                        <!-- <a type="button" title="查看参数信息" class="btn btn-default btn-sm glyphicon glyphicon-heart" 
								                           href="">
								                        </a> -->
		                                        	</div>
		                                        </td>
	                                        </tr>
	                                    </c:forEach>
	                                    </tbody>
	                                </table>
	                            </div>
	                        </div>
	                        <div class="row clearfix " align="center">
	                            <div class="col-md-12">
	                                <nav>
	                                    <ul class="pagination pagination-sm">
	
	                                    </ul>
	                                </nav>
	                            </div>
	                        </div>
	
	                    </div>
	                  </div>   
                    <!-- </div> -->
                </div>
            </div>
        </div>
    </div>
    <div id="modal-logout" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title">退出系统?</h4>
                </div>
                <div class="modal-body">
                    <p>确认对出系统吗?</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
                    <button id="logoutButton" type="button" class="btn btn-blue">是</button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>

    <div style="position:fixed;bottom:0px; width:100%;" align="center">
        <%@ include file="../include/footer.jsp" %>
    </div>
</div>

<script type="text/javascript">


	$('.pagination').twbsPagination({
	    totalPages: ${paramPageInfo.pages},
	    visiblePages: 5,
	    href: '?page={{number}}'
	}); 

	function showParameters(groupId) {
		$.ajax({
			type: "get",
			url: "${pageContext.request.contextPath}/parameter/pListForGroupId?groupId=" + groupId,
			success:function (data,textStatus) {
				$("#parameterTable").find("tbody").html("");
				for(var i=0;i<data.length;i++) {
					var row = $("<tr ></tr>");
					row.append($("<td >"+data[i].group.name+"</td>"));
					row.append($("<td >"+data[i].gParamName+"</td>"));
					row.append($("<td >"+data[i].gParamType+"</td>"));
					row.append($("<td >"+data[i].gParamValue+"</td>"));
					row.append($("<td >"+data[i].gParamRemark+"</td>"));
					row.append($("<td >"+
									"<div style='float:center;'>"+
										"<a type='button' title='编辑参数信息' class='btn btn-default btn-sm glyphicon glyphicon-edit' href='${pageContext.request.contextPath }/parameter/toEditParam?paramId="+data[i].id+"'></a>"+
										"<a type='button' title='删除参数信息' class='btn btn-default btn-sm glyphicon glyphicon-remove' onclick='openModal('${pageContext.request.contextPath }/parameter/delParam?paramId="+data[i].id+"','确定删除该参数?','删除的参数将无法恢复，是否继续?')'></a>"+
									"</div>"+
								"</td>"));
					$("#parameterTable").append(row);
				}
			},
			
			error:function () {
				console.log("错误");
			}
		})
	}
<!--

//-->

</script>

<%@ include file="../include/bottom.jsp" %>